package com.xy.model;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/*
 * 编辑套书
 */
@SuppressWarnings("serial")
@Entity
@Table
@Cacheable
public class PackageBook extends Identified implements Serializable {

	@Column(nullable = false)
	private String academyYear;// 学年
	@Column(nullable = false)
	private String semester;// 学期
	private String pdescription;// 描述
	@Column(nullable = false)
	private String grade;// 年级
	// 对应到类别表
	@ManyToOne(targetEntity = Category.class)
	@JoinColumn(name = "Category_id", referencedColumnName = "id")
	private Category category;
	// 对应到专业表
	@ManyToOne(targetEntity = Major.class)
	@JoinColumn(name = "Major_id", referencedColumnName = "id")
	private Major major;
	// 对应到层次表
	@ManyToOne(targetEntity = Level.class)
	@JoinColumn(name = "Level_id", referencedColumnName = "id")
	private Level level;
	// 对应到教材表
	@OneToMany(targetEntity = TextBook.class, mappedBy = "packageBook")
	@Cascade(value = CascadeType.SAVE_UPDATE)
	private Set<TextBook> textBooks;
	// 对应到学生领书表
	@OneToMany(targetEntity = DeliverToStudent.class, mappedBy = "packageBook") // 学生领书
	private Set<DeliverToStudent> deliverToStudents = new HashSet<DeliverToStudent>();

	public String getAcademyYear() {
		return academyYear;
	}

	public void setAcademyYear(String academyYear) {
		this.academyYear = academyYear;
	}

	public String getSemester() {
		return semester;
	}

	public void setSemester(String semester) {
		this.semester = semester;
	}

	public String getPdescription() {
		return pdescription;
	}

	public void setPdescription(String pdescription) {
		this.pdescription = pdescription;
	}

	public String getGrade() {
		return grade;
	}

	public void setGrade(String grade) {
		this.grade = grade;
	}

	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	public Major getMajor() {
		return major;
	}

	public void setMajor(Major major) {
		this.major = major;
	}

	public Level getLevel() {
		return level;
	}

	public void setLevel(Level level) {
		this.level = level;
	}

	public Set<TextBook> getTextBooks() {
		return textBooks;
	}

	public void setTextBooks(Set<TextBook> textBooks) {
		this.textBooks = textBooks;
	}

	public Set<DeliverToStudent> getDeliverToStudents() {
		return deliverToStudents;
	}

	public void setDeliverToStudents(Set<DeliverToStudent> deliverToStudents) {
		this.deliverToStudents = deliverToStudents;
	}

	public PackageBook() {
		super();
		// TODO Auto-generated constructor stub
	}

}
